//
//  SAMemberSendGroupCell.m
//  saasRetail
//
//  Created by mac on 2023/6/4.
//

#import "SAMemberSendGroupCell.h"
#import "UILabel+NSMutableAttributedString.h"
#import "SASmsAutoSendListModel.h"

@interface SAMemberSendGroupCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIView *grayView;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIButton *cartBtn;

@end

@implementation SAMemberSendGroupCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SASmsAutoSendListModel *)model {
    _model = model;
    self.titleLab.text = model.name;
    self.contentLab.text = model.content;
}

-(void)initUI {
    
    self.backgroundColor = kBgColor;
    
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.line];
    [self.bgView addSubview:self.titleLab];
    
    [self.contentView addSubview:self.grayView];
    [self.grayView addSubview:self.contentLab];
    
    [self.contentView addSubview:self.cartBtn];
    
    [self.contentLab setLineSpace:5];
    
    CGFloat imageWidth = self.cartBtn.imageView.bounds.size.width;
    CGFloat labelWidth = self.cartBtn.titleLabel.bounds.size.width;
    self.cartBtn.imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth, 0, -labelWidth);
    self.cartBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth, 0, imageWidth);
    
}

-(UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIImageView alloc] initWithFrame:SARectMake(10, 0, kBaseScreenWidth - 20, 140)];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = kScaleNum(5);
        _bgView.layer.masksToBounds = YES;
        _bgView.userInteractionEnabled = YES;
    }
    return _bgView;
}

-(UIView *)line {
    if (!_line) {
        _line = [[UIImageView alloc] initWithFrame:SARectMake(10, 10, 6, 18)];
        _line.backgroundColor = [UIColor redColor];
        _line.layer.cornerRadius = kScaleNum(3);
        _line.layer.masksToBounds = YES;
    }
    return _line;
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(26, 10, 200, 18)];
        _titleLab.font = kFont(15);
        _titleLab.textColor = kBlackColor;
        _titleLab.text = @"店庆活动";
    }
    return _titleLab;
}

-(UIView *)grayView {
    if (!_grayView) {
        _grayView = [[UIImageView alloc] initWithFrame:SARectMake(26, 38, 260, 80)];
        _grayView.backgroundColor = kBgColor;
        _grayView.layer.cornerRadius = kScaleNum(5);
        _grayView.layer.masksToBounds = YES;
        _grayView.userInteractionEnabled = YES;
    }
    return _grayView;
}

-(UILabel *)contentLab {
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] initWithFrame:SARectMake(8, 8, 244, 64)];
        _contentLab.font = kFont(14);
        _contentLab.textColor = kGrayColor;
        _contentLab.text = @"尊敬的XXX店铺会员，感恩一起走过的时光，我们的X年，XX到XX迎来周年店庆，全场XX折起，期待您的光临。";
        _contentLab.numberOfLines = 0;
    }
    return _contentLab;
}

-(UIButton *)cartBtn {
    if (!_cartBtn) {
        _cartBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cartBtn setTitle:@"设置" forState:UIControlStateNormal];
        [_cartBtn setTitleColor:kGrayColor forState:UIControlStateNormal];
        [_cartBtn setImage:[UIImage imageNamed:@"penWrite"] forState:UIControlStateNormal];
        _cartBtn.titleLabel.font = kFont(15);
        _cartBtn.frame = SARectMake(300, 68, 50, 20);
        _cartBtn.userInteractionEnabled = NO;
    }
    return _cartBtn;
}

@end
